LOLMatrix.member = (function() {
    return{

        //出生日期
        datetimepickerInit: function () {

            var curLang = LOLMatrix.common.getLang();
            var strLang = 'zh';
            if (curLang === 'en') {
                strLang = 'en';
            }


            $('#formDate').datetimepicker({
                timepicker: false,
                format: 'Y-m-d',
                lang: strLang,
                theme: "dark"
            });
        },


        //显示绑定
        showBindBox:function(){
            var bindBox=$(".bind-box"),
                liBindBtn=$(".li-bind "),
                index=0;
            if(liBindBtn.length<=0){return false;}

            //显示
            liBindBtn.on("click",function(){
                index=liBindBtn.index($(this));
                bindBox.addClass('hide').eq(index).removeClass('hide');
            });

            //关闭
            var btnClose=$(".btn-close",$(".my-account-bind-cont"));
            btnClose.on("click",function(){
                bindBox.addClass('hide');
            });
        },


        // 弹窗
        dialogCtrl:function(){
            //上传头像
            var btnUp=$(".edit-head");
            btnUp.bind("click",function(e){
                e.preventDefault();
                $(".p-win").not('div.upload-head-pic').fadeOut();
                LOLMatrix.common.dialog.showDialog($('div.upload-head-pic'));
            });
           // btnUp.click();
        },



        //电话号码 ---test
        phoneNum:function(){
            $("#phone").intlTelInput({
                // allowDropdown: false,
                // autoHideDialCode: false,
                // autoPlaceholder: false,
                // dropdownContainer: "body",
                // excludeCountries: ["us"],
                // geoIpLookup: function(callback) {
                //   $.get("http://ipinfo.io", function() {}, "jsonp").always(function(resp) {
                //     var countryCode = (resp && resp.country) ? resp.country : "";
                //     callback(countryCode);
                //   });
                // },
                // initialCountry: "auto",
                // nationalMode: false,
                // numberType: "MOBILE",
                // onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
                // preferredCountries: ['cn', 'jp'],
                // separateDialCode: true,
                utilsScript: "/res/lib/jquery/int-tel-input/js/utils.js"
            });
        },


        //上传头像---test
        uploadHead:function(){
            $('#uploadPic').fileupload({
                dataType: 'json',
                done: function (e, data) {
                    console.log(data);
                    var json={
                        success:true,
                        fileUrl:'/res/images/cont/default-avatar.png'
                    };
                    $("#resultPic").html('<img src='+json.fileUrl+'  />');
                }
            });
        }

    }
})();

$(function() {
    var member = LOLMatrix.member;
    member.datetimepickerInit();
    member.showBindBox();
    member.dialogCtrl();


    member.phoneNum();
    //member.uploadHead();
});
